function isDigit(str)
{
     var reg = /^\d+$/;
     return (reg.test(str));
}
var xmlHttp
function GetXmlHttpObject()
{
var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}
function showHocPhan(namhoc,hocki)
{ 
    document.capnhatlophp.txtmalophp.value = " ";
    document.capnhatlophp.txtkihieu.value = " ";
    document.capnhatlophp.txttuanhoc.value = " ";
    document.capnhatlophp.txtsiso.value = " ";
    //taoMaLopHP_KH(document.capnhatlophp.cbonamhoc.value,document.capnhatlophp.cbohocki.value,document.capnhatlophp.cbohp.value);
    //alert("?namhoc="+namhoc+"&hocki="+hocki);
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	 	alert ("Browser does not support HTTP Request")
	 	return
	}
	var url="xuliajax.php"
	url=url+"?form=capnhatlophp&func=hienthihp&namhoc="+namhoc+"&hocki="+hocki;
	url=url+"&sid="+Math.random()
    //alert(url);
	xmlHttp.onreadystatechange=stateChangedForshowHocPhan
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChangedForshowHocPhan() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
	 	document.getElementById("hocphan").innerHTML=xmlHttp.responseText
         taoMaLopHP_KH(document.capnhatlophp.cbonamhoc.value,document.capnhatlophp.cbohocki.value,document.capnhatlophp.cbohp.value); 
	 } 
}




function taoMaLopHP_KH(namhoc,hocki,mahp)
{ 
    //alert("?namhoc="+namhoc+"&hocki="+hocki);
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	 	alert ("Browser does not support HTTP Request")
	 	return
	}
	var url="xuliajax.php"
	url=url+"?form=capnhatlophp&func=taomalophp_kh&namhoc="+namhoc+"&hocki="+hocki+"&mahp="+mahp;
	url=url+"&sid="+Math.random()
    
	xmlHttp.onreadystatechange=stateChangedFortaoMaLopHP_KH
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChangedFortaoMaLopHP_KH() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
	   var result = xmlHttp.responseText;
       if(result != "")
       {
            var myArr = result.split("|");
            document.capnhatlophp.txtmalophp.value =  myArr[0];
            
            document.capnhatlophp.txtkihieu.value= myArr[1];
            //document.getElementById("table").innerHTML= myArr[2];
        }

	 	//document.getElementById("malophp").innerHTML=xmlHttp.responseText 
        //document.getElementById("kh").innerHTML=xmlHttp.responseText 
	 } 
}
function showTenCB(maso)
{ 
    //alert("?namhoc="+namhoc+"&hocki="+hocki);
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	 	alert ("Browser does not support HTTP Request")
	 	return
	}
	var url="xuliajax.php"
	url=url+"?form=capnhatlophp&func=hienthitencb&maso="+maso;
	url=url+"&sid="+Math.random()
    
	xmlHttp.onreadystatechange=stateChangedForshowTenCB
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChangedForshowTenCB() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
	  
            
            document.getElementById("tencb").innerHTML=xmlHttp.responseText 
            
         
	 } 
}

function xepPhong(siso,thu,tietbd,sotiet)
{ 
    
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	 	alert ("Browser does not support HTTP Request");
	 	return;
	}
	var url="xuliajax.php";
    url = url + "?form=capnhattkb&func=xepphong&siso=" + siso + "&thu=" + thu + "&tietbd= " + tietbd + "&sotiet=" + sotiet;
	//  url=url+"?form=capnhattkb&func=xepphong&siso="+siso."&thu="+thu."&tietbd="+tietbd."&sotiet="+sotiet;
	url=url+"&sid="+Math.random();
    //alert(url);
    
	xmlHttp.onreadystatechange=stateChangedForxepPhong;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateChangedForxepPhong() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    { 	              
        document.getElementById("maphong").innerHTML=xmlHttp.responseText                     
    } 
}

function showHPXemNhatKi(namhoc,hocki)
{ 
  
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	 	alert ("Browser does not support HTTP Request")
	 	return
	}
	var url="xuliajax.php"
	url=url+"?form=xemnhatki&func=hienthihp&namhoc="+namhoc+"&hocki="+hocki;
	url=url+"&sid="+Math.random()
    //alert(url);
	xmlHttp.onreadystatechange=stateChangedForshowHPXemNhatKi
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChangedForshowHPXemNhatKi() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
	 	document.getElementById("hocphan").innerHTML=xmlHttp.responseText
        //taoMaLopHP_KH(document.capnhatlophp.cbonamhoc.value,document.capnhatlophp.cbohocki.value,document.capnhatlophp.cbohp.value); 
	 } 
}

function showLopHPXemNhatKi(namhoc,hocki,mahp)
{ 
  //alert("url");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	 	alert ("Browser does not support HTTP Request")
	 	return
	}
	var url="xuliajax.php"
	url=url+"?form=xemnhatki&func=hienthilophp&namhoc="+namhoc+"&hocki="+hocki+"&mahp="+mahp;
	url=url+"&sid="+Math.random()
    
	xmlHttp.onreadystatechange=stateChangedForshowLopHPXemNhatKi
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChangedForshowLopHPXemNhatKi() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
	 	document.getElementById("lophp").innerHTML=xmlHttp.responseText
         //taoMaLopHP_KH(document.capnhatlophp.cbonamhoc.value,document.capnhatlophp.cbohocki.value,document.capnhatlophp.cbohp.value); 
	 } 
}


function showBMTheoKhoa(makhoa)
{ 
    //url="index.php?option=xemnhatki&makhoa="+makhoa;
    //alert(url);
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	 	alert ("Browser does not support HTTP Request")
	 	return
	}
	var url="xuliajax.php";
	url=url+"?func=hienthibmtheokhoa&makhoa="+makhoa;
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
	 	document.getElementById("bomon").innerHTML=xmlHttp.responseText 
	 } 
}

function dsHPTheoChuyenNganh(manganh)
{ 
    //alert("?namhoc="+namhoc+"&hocki="+hocki);
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	 	alert ("Browser does not support HTTP Request")
	 	return
	}
	var url="xuliajax.php"
	url=url+"?form=capnhatctdt&func=hienthidshptheochuyennganh&manganh="+manganh;
	url=url+"&sid="+Math.random()
    //alert(url);
	xmlHttp.onreadystatechange=stateChangedFordsHPTheoChuyenNganh
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChangedFordsHPTheoChuyenNganh() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
	   
	 	
        document.getElementById("table").innerHTML=xmlHttp.responseText 
	 } 
}

function hienThiHPTheoNganh(manganh)
{ 
  
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	 	alert ("Browser does not support HTTP Request")
	 	return
	}
	var url="xuliajax.php"
	url=url+"?form=xemdecuong&func=hienThiHPTheoNganh&manganh="+manganh;
	url=url+"&sid="+Math.random()
    //alert(url);
	xmlHttp.onreadystatechange=stateChangedForhienThiHPTheoNganh
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChangedForhienThiHPTheoNganh() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
        
	 	document.getElementById("hocphan").innerHTML=xmlHttp.responseText
        document.xemdecuong.cbohp.selectedIndex = 0;
        //taoMaLopHP_KH(document.capnhatlophp.cbonamhoc.value,document.capnhatlophp.cbohocki.value,document.capnhatlophp.cbohp.value); 
	 } 
}


function hienThiThongTinHP(mahp){
    xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	 	alert ("Browser does not support HTTP Request")
	 	return
	}
	var url="xuliajax.php"
	url=url+"?form=capnhathp&func=hienthithongtinHP&mahp="+mahp;
	url=url+"&sid="+Math.random()
    //alert(mahp);
	xmlHttp.onreadystatechange=stateChangedForhienThiThongTinHP
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChangedForhienThiThongTinHP() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 {  
	   var result = xmlHttp.responseText;
       if(result != " ")
       {
            var myArr = result.split("|");
            //$tenhp = stripslashed();
            
            document.capnhathp.txttenhp.value =  myArr[0];
            document.capnhathp.txtsotc.value= myArr[1];
            document.capnhathp.txtsotietlt.value= myArr[2];
            document.capnhathp.txtsotietth.value= myArr[3];
            document.capnhathp.txthptienquyet.value= myArr[4];
            
            for(var i=0;i<document.capnhathp.cbonhomhp.length;i++){
    		  if(document.capnhathp.cbonhomhp[i].value==myArr[5]){
    			document.capnhathp.cbonhomhp.selectedIndex=i;
    		  }
    	   }
            nicEditors.findEditor('txtthongtingv').setContent(myArr[6]);
            
            nicEditors.findEditor('txtmuctieu').setContent(myArr[8]);
            nicEditors.findEditor('txtppgiangday').setContent(myArr[9]);                                   
            nicEditors.findEditor('txtdanhgiahp').setContent(myArr[10]);
            nicEditors.findEditor('txttailieuthamkhao').setContent(myArr[11]);
            document.capnhathp.btnthem.disabled = false;
            document.capnhathp.btnsua.disabled = true;
            document.capnhathp.btnxoa.disabled = true;                        
        }

	 	
	 }
     
}
function hienThiDCCTCuaHP(mahp)
{ 
  
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	 	alert ("Browser does not support HTTP Request")
	 	return
	}
	var url="xuliajax.php"
	url=url+"?form=capnhatdcct&func=hienThiDCCTCuaHP&mahp="+mahp;
	url=url+"&sid="+Math.random()
    //alert(url);
	xmlHttp.onreadystatechange=stateChangedForhienThiDCCTCuaHP
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChangedForhienThiDCCTCuaHP() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
        var result = xmlHttp.responseText;
        if(result != "")
        {
            //alert("Hello");
            var myArr = result.split("|");
            //if (myArr.length==2){
                document.capnhatdcct.txtmadc.value = myArr[0];
                document.getElementById("decuong").innerHTML=myArr[1];
            //}
             //if (myArr.length==1)
                //document.capnhatdcct.txtmadc.value = myArr[0];
        }
         
	 } 
}


function hienThiDSChucNang(maquyen)
{ 
  
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	 	alert ("Browser does not support HTTP Request")
	 	return
	}
	var url="xuliajax.php"
	url=url+"?form=phanquyen&maquyen="+maquyen;
	url=url+"&sid="+Math.random()
    //alert(maquyen);
	xmlHttp.onreadystatechange=stateChangedForhienThiDSChucNang
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChangedForhienThiDSChucNang() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
        var result = xmlHttp.responseText;
        if(result != "")
        {
            
                document.getElementById("danhsachcn").innerHTML=xmlHttp.responseText;
            
        }
         
	 } 
}

function nhapThongTinCB(loaicb)
{ 
  
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	 	alert ("Browser does not support HTTP Request")
	 	return
	}
	var url="xuliajax.php"
	url=url+"?form=capnhatcanbo&loaicb="+loaicb;
	url=url+"&sid="+Math.random()
    //alert(maquyen);
	xmlHttp.onreadystatechange=stateChangedFornhapThongTinCB
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChangedFornhapThongTinCB() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
        var result = xmlHttp.responseText;
        if(result != "")
        {
            
                document.getElementById("nhapttcb").innerHTML=xmlHttp.responseText;
            
        }
         
	 } 
}
function taoMaCB()
{ 
  
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	 	alert ("Browser does not support HTTP Request")
	 	return
	}
	var url="xuliajax.php"
	url=url+"?form=capnhatcanbo&func=taomacb";
	url=url+"&sid="+Math.random()
    //alert(maquyen);
	xmlHttp.onreadystatechange=stateChangedFortaoMaCB
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChangedFortaoMaCB() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
        var result = xmlHttp.responseText;
        if(result != "")
        {
            
                document.capnhatcanbo.txtmaso.value=xmlHttp.responseText;
            
        }
         
	 } 
}
function hienThiThongTinCB(loaicb,maso)
{ 
	if(maso.length<7) return;
  
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	 	alert ("Browser does not support HTTP Request")
	 	return
	}
	var url="xuliajax.php"
	url=url+"?form=capnhatcanbo&func=hienthittcb&loaicb="+loaicb+"&maso="+maso;
	url=url+"&sid="+Math.random()
    //alert(maquyen);
	xmlHttp.onreadystatechange=stateChangedForhienThiThongTinCB
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChangedForhienThiThongTinCB() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
        var result = xmlHttp.responseText;
        if(result != "")
        {
            //dsTatCaBM();
            var myArr = result.split("|");            
            document.capnhatcanbo.txtholot.value = myArr[0];
            document.capnhatcanbo.txtten.value=myArr[1];
            document.capnhatcanbo.txtngaysinh.value=myArr[2];
            for(var i=0;i<document.capnhatcanbo.cbophai.length;i++){
    		  if(document.capnhatcanbo.cbophai[i].value==myArr[3]){
    			document.capnhatcanbo.cbophai.selectedIndex=i;
    		  }
	       }
            document.capnhatcanbo.txtdiachi.value=myArr[4];
            document.capnhatcanbo.txtemail.value=myArr[5];
            document.capnhatcanbo.txtsodt.value=myArr[6];
            for(var i=0;i<document.capnhatcanbo.cbohocvi.length;i++){
    		  if(document.capnhatcanbo.cbohocvi[i].value==myArr[7]){
    			document.capnhatcanbo.cbohocvi.selectedIndex=i;
                break;
    		  }
	       }
            document.capnhatcanbo.txtnghiepvu.value=myArr[8];
           
            //alert('maso = ' + myArr[9]);
            for(var i=0;i<document.capnhatcanbo.cbobomon.length;i++){
    		  if(document.capnhatcanbo.cbobomon[i].value==myArr[9]){
    			document.capnhatcanbo.cbobomon.selectedIndex=i;
                break;
    		  }
              //cbochucdanh
	       }
           
          
          for(var i=0;i<document.capnhatcanbo.cbochucdanh.length;i++){
    		  if(document.capnhatcanbo.cbochucdanh[i].value==myArr[10]){
    			document.capnhatcanbo.cbochucdanh.selectedIndex=i;
                break;
    		  }
              //else document.capnhatcanbo.cbochucdanh.selectedIndex=0;
	       }
           for(var i=0;i<document.capnhatcanbo.cbochucvu.length;i++){
    		  if(document.capnhatcanbo.cbochucvu[i].value==myArr[11]){
    			document.capnhatcanbo.cbochucvu.selectedIndex=i;
                break;
    		  }
              //else document.capnhatcanbo.cbochucvu.selectedIndex=0;
	       }
           /*var ten = trim(myArr[1])
            if (ten != ""){
                document.capnhatcanbo.txtmaso.readOnly = true;
                 document.capnhatcanbo.txtmaso.style.backgroundColor = '#cccccc'; 
                  document.capnhatcanbo.btnsua.disabled=false;
           document.capnhatcanbo.btnxoa.disabled=false;
            }*/
	      	
          
           
        }
         
	 } 
}

function dsTatCaBM()
{ 
    //url="index.php?option=xemnhatki&makhoa="+makhoa;
    //alert(url);
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	 	alert ("Browser does not support HTTP Request")
	 	return
	}
	var url="xuliajax.php";
	url=url+"?func=hienthidsbm";
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChangedFordsTatCaBM
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChangedFordsTatCaBM() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
	 	document.getElementById("bomon").innerHTML=xmlHttp.responseText 
	 } 
}
